<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PhotoLib-通用相册模板</title>
<!--
Copyright (c) [2019] [name of copyright holder]
[Software Name] is licensed under the Mulan PSL v1.
You can use this software according to the terms and conditions of the Mulan PSL v1.
You may obtain a copy of Mulan PSL v1 at:
    http://license.coscl.org.cn/MulanPSL
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
PURPOSE.
See the Mulan PSL v1 for more details.
-->
<script LANGUAGE="JavaScript">
<!--
//作者：http://haitao.appinn.me  http://haitaosite.cn  http://szhaitao.orgw.net  http://haitaosite.bplaced.net
//demo: http://haitaosite.cn/shenzhen/



var imgs=new Array();	
function isNull(arg1)
{
	return !arg1 && arg1!==0 && typeof arg1!=="boolean"?true:false;
}
 
function getarg(name) { 
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
var r = window.location.search.substr(1).match(reg); 
if (r != null) return decodeURIComponent(r[2]); return null; //unescape
}

var shtml="";
function ln()
{
	shtml=shtml+"<br>";
}
function w(s)
{
  shtml=shtml+s;
}
function wln(s)
{
  shtml=shtml+s;
  ln();
}

function sethtml(o)
{
  document.getElementById(o).innerHTML=shtml;
}


var title=getarg("title");
var dir="";
var photodirs=getarg("dirlist");
var dirnames=getarg("namelist");




var xmlHttp = null;
function loadjs()
{
try {
  //Firefox, Opera 8.0+, Safari
  xmlHttp = new XMLHttpRequest();
} catch (e) {
  //IE
  try {
    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
}
if(!xmlHttp) 
  alert("您的浏览器不支持AJAX！");
else {
var js=dir+"/photolib.js";
xmlHttp.onreadystatechange = function() {
  if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
    eval(xmlHttp.responseText);
}
xmlHttp.open("POST", js, false);
xmlHttp.send(null);
}
}



function showlist(sdir,n)
{
  dir=sdir;
  imgs.length=0;
  curp=-1;
  loadjs();
  outlist(0);
  document.getElementById('curdir').innerHTML='正在浏览：'+n;
}




var selfurl=location.pathname;


function showimg(img)	{
	if (1==tosmall)
	{	oldw=img.width;
		if (img.width>ww)
		{
			if (img.height*ww/img.width>hh)
			{	img.width=oldw*hh/img.height;
			}
			else
				img.width=ww;
		}
		else
		if (img.height>hh)
		{
			if (img.width*hh/img.height>ww)
			{	img.width=oldw*ww/img.height;
			}
			else
				img.width=hh/img.height*oldw;
		}
			
		tosmall=0;
	}
	else
	{	img.width=oldw;
		tosmall=1;
	}
}

var dx='15px'; var dy='15px'; var dx1='205px'; var dy1='70px'; var iconx=16*4;
iconx=' width='+iconx+' height='+iconx;
var divxy='<div id="divMessage" name="divgo" style="position: fixed;top: '+dy+'px;right: '+dx+'px;z-index: 100;">'
+'<a title=显示前一张 href=javascript:gonext(-1); ><img border="0" src=/img/tol.gif'+iconx+'></a>'
+' <a title=切换本图标位置 href=javascript:newxy(); ><img border="0" src=/img/xy.gif'+iconx+'></a>'
+' <a title=显示后一张 href=javascript:gonext(1); ><img border="0" src=/img/tor.gif'+iconx+'></a></div>';
function rexy()
{
var v=divMessage.style;
if (xy==0) { v.left=dx1; v.right=''; v.top=dy1; v.bottom=''; }
if (xy==1) { v.left='';  v.right=dx; v.top=dy1; v.bottom=''; }
if (xy==2) { v.left='';  v.right=dx; v.top='';  v.bottom=dy; }
if (xy==3) { v.left=dx1; v.right=''; v.top='';  v.bottom=dy; }
}
function newxy()
{
++xy;
if (xy>3) xy=0;
rexy();
}



function showright(u)
{  curp=u;

shtml='';
ww=document.documentElement.clientWidth-15-181;	oldw=0; 	
tosmall=1;
hh=document.documentElement.clientHeight-15-55;
		var timg=imgs[u];
		var uc;
if (dirmode != "1")
{ uc=timg.substring(8);
  aurl=dir+'/../'+uc;
}
else
{ uc=timg;
  aurl=dir+'/'+uc;
}


shtml='';
w(divxy);
w('<img src='+aurl+' onload="showimg(this);" onClick="showimg(this);" alt="点击图片：按原始大小观看"><br><img border="0" alt="photo set hit counter" src="/count/?w=photo'+dir+'/'+uc+'"></body>'); //root+
sethtml('right');
  
rexy();

}

function gonext(u)
{ if (curp*1+u<0)  return;
  if (curp*1+u>=imgs.length) return;
	showright(curp*1+u);
}


curp=-1;

function showsmall(u)
{
	return "href=javascript:showright('"+u+"');";
}





function outlist(p){
  var pn=20;
	var n=imgs.length;
  if(!n) n=0; 
		
	var s="共"+n+"张 \n";
	if (n>0)
	{
	var t="";
	if (n>pn)
	{
    for (i=0; i<=parseInt((n-1)/pn); i++)
      if (i==p)
        t=t+ " ["+(i+1)+"]";
      else
        t=t+ " <a href=javascript:outlist("+i+");>["+(i+1)+"]</a>";
    t=t+"<br>\n";
	}
  s=s+t+"<hr>\n";
	for (i=pn*p; i<pn*(p+1); i++)
	{
    if (i>=n) break;    
		s=s+ ((i+1)+"/"+n+":<br><a "+showsmall(i)+"><img src='"+dir+"/s/"+imgs[i]+"' border=0></a><hr>\n");
	}
	}
	document.getElementById('left').innerHTML = s+t
	  +'<br><img border="0" alt="photo dir hit counter" src="/count/?w=photo'+dir+'">'; //+root

}


var xy=1; var curp=-1; var dirmode=getarg("dirmode");
var root=getarg("root");

document.title=title;



//-->
</script>
</head>
<body bgcolor=#FFFFFF text=#000000>

<div id="top" style="margin:0px; padding:2px; position:fixed; left:0px; top:0px; right:0px; height:55px; border:1px solid #7F7;overflow:auto;background:#ddd;" ></div>
<div id="left" style="margin:0px; padding:2px; position:fixed; left:0px; top:56px; width:180px; bottom:0px; border:1px solid #F88;overflow-y:auto;background:#ede;" >
  请先在上面选择图库目录。。。
</div>
<div id="right" style="margin:0px; padding:2px; position:fixed; left:183px; top:56px; right:0px; bottom:0px; border:1px solid #77F;overflow:auto;background:#eed;" >
  请先在上面选择图库目录，左边会显示对应的缩略图列表，<br>再点击左边列表里的小图，这里会显示对应的大图，<br>点击大图则 切换到 原始大小 或 全部显示
</div>

<script LANGUAGE="JavaScript">
<!--
shtml="";
		w("<center><b>"+title+"</b> &nbsp; <img border='0' alt='photo set hit counter' src='/count/?w=photo"+root+"'> &nbsp; （<span id=curdir>点击下面链接 选择图库目录</span>）<br>");
		var nms=dirnames;
		var links=photodirs;
		var qs = links.split('|');
		var ns=nms.split('|');
		if (ns.length!=qs.length) ns=qs;
		if (qs) { //w('点击右边链接 选择图库目录： ');
			for (var i=0;i<qs.length;i++) {
				w('<a href=javascript:showlist(\''+root+qs[i]+'\',\''+ns[i]+'\'); >'+ns[i]+'</a> &nbsp; '); //onclick=
			}
		}
		w("</center>");
sethtml('top');
 

//-->
</script>

</body>

